import { appPort } from "./config/appSetting.js";
import Koa from "koa";
import Router from "koa-router";

//第一步 创建实例
let app = new Koa();
let router = new Router();

//第二步 创建一个中间键
app.use(async (ctx, next) => {
    await next();
})

router.get('/blogs', async(ctx, next) => {
    ctx.body = '列表'
})

router.get('/blogs/:id', async(ctx, next) => {
    ctx.body = '指定博客'
})
  
router.post('/blogs', async(ctx, next) => {
    ctx.body = '新增'
})

router.put('/blogs/:id', async(ctx, next) => {
    ctx.body = '修改'
})

router.delete('/blogs/:id', async(ctx, next) => {
    ctx.body = '删除'
})


app.use(router.routes());

//第三步 监听
app.listen(appPort)

//第四步 打印服务地址
console.log(`服务器运行在如下地址：http://localhost:${appPort}`);
